mirror of
				https://github.com/KevinMidboe/vue-js-modal.git
				synced 2025-10-29 18:00:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			70 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var parser = require('../../src/parser')
 | |
| var { expect } = require('chai')
 | |
| 
 | |
| describe('parser.js', () => {
 | |
|   describe('#parse', () => {
 | |
|     describe('Correct types', () => {
 | |
|       it('Should parse numbers', () => {
 | |
|         let object = parser.parse(10)
 | |
| 
 | |
|         expect(object.value).to.be.a('number')
 | |
|         expect(object.type).to.be.a('string')
 | |
| 
 | |
|         expect(object.value).to.equal(10)
 | |
|         expect(object.type).to.equal('px')
 | |
|       })
 | |
| 
 | |
|       it('Should parse strings', () => {
 | |
|         let object = parser.parse('10')
 | |
| 
 | |
|         expect(object.value).to.be.a('number')
 | |
|         expect(object.type).to.be.a('string')
 | |
| 
 | |
|         expect(object.value).to.equal(10)
 | |
|         expect(object.type).to.equal('px')
 | |
|       })
 | |
| 
 | |
|       it ('Should parse "auto" string, auto => {type: "auto", value: 0}', () => {
 | |
|         let object = parser.parse('auto')
 | |
| 
 | |
|         expect(object.value).to.equal(0)
 | |
|         expect(object.type).to.equal('auto')
 | |
|       })
 | |
| 
 | |
|       it ('Should parse wrong types', () => {
 | |
|         let nullValue = parser.parse(null)
 | |
|         let booleanValue = parser.parse(false)
 | |
| 
 | |
|         expect(nullValue.value).to.equal(null)
 | |
|         expect(nullValue.type).to.equal('')
 | |
| 
 | |
|         expect(booleanValue.value).to.equal(false)
 | |
|         expect(booleanValue.type).to.equal('')
 | |
|       })
 | |
|     })
 | |
| 
 | |
|     describe('Parsing suffixed string', () => {
 | |
|       it ('Should parse "px"', () => {
 | |
|         let object = parser.parse('10px')
 | |
| 
 | |
|         expect(object.value).to.equal(10)
 | |
|         expect(object.type).to.equal('px')
 | |
|       })
 | |
| 
 | |
|       it ('Should parse "%"', () => {
 | |
|         let object = parser.parse('10%')
 | |
| 
 | |
|         expect(object.value).to.equal(10)
 | |
|         expect(object.type).to.equal('%')
 | |
|       })
 | |
| 
 | |
|       it ('Should not parse "%px"', () => {
 | |
|         let object = parser.parse('10%px')
 | |
| 
 | |
|         expect(object.value).to.be.a('string')
 | |
|         expect(object.type).to.equal('')
 | |
|       })
 | |
|     })
 | |
|   })
 | |
| })
 |