-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
77 lines (67 loc) · 1.92 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
'use strict'
import { describe, it, before } from 'mocha'
import { expect } from 'chai'
import webpack from 'webpack'
import MemoryFileSystem from 'memory-fs'
import Plugin from '../index'
import config, { data } from './webpack.config'
const compiler = webpack({...config, output: {...config.output, path: '/'}})
compiler.outputFileSystem = new MemoryFileSystem()
describe('ReactRouterPathExtractorWebpackPlugin', () => {
describe('constructor', () => {
const subject = (...args) => () => new Plugin(...args)
describe('0 arguments', () => {
it('should throw an error', () => {
expect(subject()).to.throw(Error, 'Invalid arguments')
})
})
describe('1 argument', () => {
it('should throw an error', () => {
expect(subject()).to.throw(Error, 'Invalid arguments')
})
})
})
describe('.apply', () => {
let error = null
before(function (done) {
this.timeout(0)
compiler.run((err, stats) => {
error = err
done()
})
})
describe('compiler', () => {
it('should not error', () => {
expect(error).to.be.null
})
})
describe('callback', () => {
it('should include the expected paths', () => {
var expected = [
'/',
'/nested/1',
'/nested/1/1.1/1.1.1',
'/nested/1/1.2/1.2.1',
'/nested/1/1.2/1.2.1/1.2.1.1',
'/nested/2',
'/nested/2/2.1/2.1.1',
'/foobar',
'/foobar/whatever',
'/foobar/whatever/something/something',
'/foobar/whatever/nomatch',
'/error'
]
expect(data.paths).to.have.members(expected)
})
it('should exculde the expected paths', () => {
var unexpected = [
'/nested',
'/nested/1/1.1',
'/nested/1/1.2',
'/nested/2/2.1'
]
expect(data.paths).to.not.have.members(unexpected)
})
})
})
})