scratch – Blame information for rev 134
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
134 | office | 1 | var jsdom = require('jsdom'); |
2 | require('./helpers/jsdom-patch'); |
||
3 | |||
4 | before(function (done) { |
||
5 | jsdom.env({ |
||
6 | html: '<html><body></body></html>', |
||
7 | done: function (err, window) { |
||
8 | |||
9 | // Set clientTop and clientLeft to 0 so that offset() works |
||
10 | window.document.documentElement.clientTop = 0; |
||
11 | window.document.documentElement.clientLeft = 0; |
||
12 | |||
13 | // Expose jQuery and require tokenfield |
||
14 | window.$ = global.$ = global.jQuery = require('jquery')(window); |
||
15 | require('../js/bootstrap-tokenfield')(window); |
||
16 | |||
17 | // Globalize window, document, navigator |
||
18 | global.window = window; |
||
19 | global.document = window.document; |
||
20 | global.navigator = window.navigator; |
||
21 | |||
22 | // Provide a focus method on DOM elements if it does not exist. |
||
23 | // Helps to avoid issues with the simulate-ext plugin |
||
24 | window.HTMLDivElement.prototype.focus = window.HTMLDivElement.prototype.focus || function() {}; |
||
25 | |||
26 | // Global configuration object for our tests |
||
27 | global.TFT = window.TFT = {}; |
||
28 | |||
29 | done(); |
||
30 | } |
||
31 | }); |
||
32 | }); |
||
33 | |||
34 | // Global tokenfield test object |
||
35 | beforeEach(function() { |
||
36 | var template = TFT.template || '<input type="text" class="tokenize" value="" />', |
||
37 | options = TFT.options || null; |
||
38 | |||
39 | this.$sandbox = $('<div />').appendTo($('body')); |
||
40 | this.$template = $(template).appendTo(this.$sandbox); |
||
41 | |||
42 | this.$field = this.$template.hasClass('tokenize') ? this.$template : this.$template.find('.tokenize'); |
||
43 | this.$field.tokenfield( options ); |
||
44 | |||
45 | // Shortcuts |
||
46 | this.$input = this.$field.data('bs.tokenfield').$input; |
||
47 | this.$wrapper = this.$field.data('bs.tokenfield').$wrapper; |
||
48 | this.$copyHelper = this.$field.data('bs.tokenfield').$copyHelper; |
||
49 | |||
50 | // Set an initial empty value for inputs (workaround for bililiteRange `null` value error) |
||
51 | this.$input.val(''); |
||
52 | this.$copyHelper.val(''); |
||
53 | }); |
||
54 | |||
55 | afterEach( function() { |
||
56 | this.$field.tokenfield('destroy'); |
||
57 | this.$sandbox.remove(); |
||
58 | |||
59 | delete this.$field; |
||
60 | delete this.$input; |
||
61 | delete this.$wrapper; |
||
62 | delete this.$copyHelper; |
||
63 | delete this.$sandbox; |
||
64 | delete this.$template; |
||
65 | }); |