-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
41 lines (30 loc) · 1.16 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict'
var expect = require('chai').expect
var str_is = require('./index')
describe('#str_is', function () {
it('should throw an exception if one of the arguments are not string', function () {
var argumentsAreNotString = function () {
return str_is(1, Object.create(null))
}
expect(argumentsAreNotString).to.throw(TypeError)
})
it('should returns true if pattern and value are same', function () {
var result = str_is('foo/bar', 'foo/bar')
expect(result).to.be.true
})
it('should returns true if pattern is "foo/bar/*" and value is "foo/bar/baz"', function () {
var result = str_is('foo/bar/*', 'foo/bar/baz')
expect(result).to.be.true
})
it('should returns false if pattern is "foo/bar/*" and value is "foo/baz/bar"', function () {
var result = str_is('foo/bar/*', 'foo/baz/bar')
expect(result).to.be.false
})
it('can call the "is" method for the String instances', function () {
var stringInstancesCanCallIsMethod = function () {
return 'foobar'.is('foo*')
}
expect(stringInstancesCanCallIsMethod).to.not.throw(TypeError)
expect(stringInstancesCanCallIsMethod()).to.be.true
})
})