-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.js
31 lines (26 loc) · 940 Bytes
/
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
const licenseOMatic = require('./')
test('should be defined', () => {
expect(licenseOMatic).toBeDefined()
expect(typeof licenseOMatic).toBe('object')
})
test('should get license identifier', () => {
const identifiers = licenseOMatic.getIdentifiers()
expect(Array.isArray(identifiers)).toBeTruthy()
})
test('should create MIT license', () => {
const mit = licenseOMatic.getLicense('mit')
const name = 'foooper'
const licenseStr = mit({copyrightHolder: name})
expect(licenseStr.indexOf(name) !== -1).toBeTruthy()
})
test('should throw if license does not exist', () => {
expect(() => licenseOMatic.getLicense('fooopper')).toThrow()
})
test('can generate all licenses', () => {
const identifiers = licenseOMatic.getIdentifiers()
const allLicenses = identifiers.every(id => {
const license = licenseOMatic.getLicense(id)
return license({copyrightHolder: 'foooper'})
})
expect(allLicenses).toBeTruthy()
})