|
|
@@ -86,27 +86,27 @@ describe('UNIT: Directive', function () {
|
|
|
})
|
|
|
|
|
|
it('should return undefined if directive is unknown', function () {
|
|
|
- var d = Directive.parse('v-directive-that-does-not-exist', 'abc', compiler)
|
|
|
+ var d = Directive.parse('directive-that-does-not-exist', 'abc', compiler)
|
|
|
assert.ok(d === undefined)
|
|
|
})
|
|
|
|
|
|
it('should return undefined if the expression is invalid', function () {
|
|
|
- var e = Directive.parse('v-text', ' ', compiler),
|
|
|
- f = Directive.parse('v-text', '|', compiler),
|
|
|
- g = Directive.parse('v-text', ' | ', compiler)
|
|
|
+ var e = Directive.parse('text', ' ', compiler),
|
|
|
+ f = Directive.parse('text', '|', compiler),
|
|
|
+ g = Directive.parse('text', ' | ', compiler)
|
|
|
assert.strictEqual(e, undefined, 'spaces')
|
|
|
assert.strictEqual(f, undefined, 'single pipe')
|
|
|
assert.strictEqual(g, undefined, 'pipe with spaces')
|
|
|
})
|
|
|
|
|
|
it('should return a simple Directive if expression is empty', function () {
|
|
|
- var d = Directive.parse('v-text', '', compiler)
|
|
|
+ var d = Directive.parse('text', '', compiler)
|
|
|
assert.ok(d instanceof Directive)
|
|
|
assert.ok(d.isSimple)
|
|
|
})
|
|
|
|
|
|
it('should return an instance of Directive if args are good', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler)
|
|
|
+ var d = Directive.parse('text', 'abc', compiler)
|
|
|
assert.ok(d instanceof Directive)
|
|
|
})
|
|
|
|
|
|
@@ -126,12 +126,12 @@ describe('UNIT: Directive', function () {
|
|
|
directives.obj = obj
|
|
|
|
|
|
it('should copy the definition as _update if the def is a function', function () {
|
|
|
- var d = Directive.parse('v-test', 'abc', compiler)
|
|
|
+ var d = Directive.parse('test', 'abc', compiler)
|
|
|
assert.strictEqual(d._update, test)
|
|
|
})
|
|
|
|
|
|
it('should copy methods if the def is an object', function () {
|
|
|
- var d = Directive.parse('v-obj', 'abc', compiler)
|
|
|
+ var d = Directive.parse('obj', 'abc', compiler)
|
|
|
assert.strictEqual(d._update, obj.update, 'update should be copied as _update')
|
|
|
assert.strictEqual(d._unbind, obj.unbind, 'unbind should be copied as _unbind')
|
|
|
assert.strictEqual(d.bind, obj.bind)
|
|
|
@@ -140,36 +140,36 @@ describe('UNIT: Directive', function () {
|
|
|
|
|
|
it('should trim the expression', function () {
|
|
|
var exp = ' fsfsef | fsef a ',
|
|
|
- d = Directive.parse('v-text', exp, compiler)
|
|
|
+ d = Directive.parse('text', exp, compiler)
|
|
|
assert.strictEqual(d.expression, exp.trim())
|
|
|
})
|
|
|
|
|
|
it('should extract correct key', function () {
|
|
|
- var d = Directive.parse('v-text', '"fsefse | fsefsef" && bc', compiler),
|
|
|
- e = Directive.parse('v-text', '"fsefsf & fsefs" | test', compiler),
|
|
|
- f = Directive.parse('v-text', '"fsef:fsefsf" || ff', compiler)
|
|
|
+ var d = Directive.parse('text', '"fsefse | fsefsef" && bc', compiler),
|
|
|
+ e = Directive.parse('text', '"fsefsf & fsefs" | test', compiler),
|
|
|
+ f = Directive.parse('text', '"fsef:fsefsf" || ff', compiler)
|
|
|
assert.strictEqual(d.key, '"fsefse | fsefsef" && bc', 'pipe inside quotes and &&')
|
|
|
assert.strictEqual(e.key, '"fsefsf & fsefs"', '& inside quotes with filter')
|
|
|
assert.strictEqual(f.key, '"fsef:fsefsf" || ff', ': inside quotes and ||')
|
|
|
})
|
|
|
|
|
|
it('should extract correct argument', function () {
|
|
|
- var d = Directive.parse('v-text', 'todo:todos', compiler),
|
|
|
- e = Directive.parse('v-text', 'todo:todos + abc', compiler),
|
|
|
- f = Directive.parse('v-text', 'todo:todos | fsf fsef', compiler)
|
|
|
+ var d = Directive.parse('text', 'todo:todos', compiler),
|
|
|
+ e = Directive.parse('text', 'todo:todos + abc', compiler),
|
|
|
+ f = Directive.parse('text', 'todo:todos | fsf fsef', compiler)
|
|
|
assert.strictEqual(d.arg, 'todo', 'simple')
|
|
|
assert.strictEqual(e.arg, 'todo', 'expression')
|
|
|
assert.strictEqual(f.arg, 'todo', 'with filters')
|
|
|
})
|
|
|
|
|
|
it('should be able to determine whether the key is an expression', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler),
|
|
|
- e = Directive.parse('v-text', '!abc', compiler),
|
|
|
- f = Directive.parse('v-text', 'abc + bcd * 5 / 2', compiler),
|
|
|
- g = Directive.parse('v-text', 'abc && (bcd || eee)', compiler),
|
|
|
- h = Directive.parse('v-text', 'test(abc)', compiler),
|
|
|
- i = Directive.parse('v-text', 'a.b', compiler),
|
|
|
- j = Directive.parse('v-text', 'a.$b', compiler)
|
|
|
+ var d = Directive.parse('text', 'abc', compiler),
|
|
|
+ e = Directive.parse('text', '!abc', compiler),
|
|
|
+ f = Directive.parse('text', 'abc + bcd * 5 / 2', compiler),
|
|
|
+ g = Directive.parse('text', 'abc && (bcd || eee)', compiler),
|
|
|
+ h = Directive.parse('text', 'test(abc)', compiler),
|
|
|
+ i = Directive.parse('text', 'a.b', compiler),
|
|
|
+ j = Directive.parse('text', 'a.$b', compiler)
|
|
|
assert.ok(!d.isExp, 'non-expression')
|
|
|
assert.ok(e.isExp, 'negation')
|
|
|
assert.ok(f.isExp, 'math')
|
|
|
@@ -180,11 +180,11 @@ describe('UNIT: Directive', function () {
|
|
|
})
|
|
|
|
|
|
it('should have a filter prop of null if no filters are present', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler),
|
|
|
- e = Directive.parse('v-text', 'abc |', compiler),
|
|
|
- f = Directive.parse('v-text', 'abc ||', compiler),
|
|
|
- g = Directive.parse('v-text', 'abc | | ', compiler),
|
|
|
- h = Directive.parse('v-text', 'abc | unknown | nothing at all | whaaat', compiler)
|
|
|
+ var d = Directive.parse('text', 'abc', compiler),
|
|
|
+ e = Directive.parse('text', 'abc |', compiler),
|
|
|
+ f = Directive.parse('text', 'abc ||', compiler),
|
|
|
+ g = Directive.parse('text', 'abc | | ', compiler),
|
|
|
+ h = Directive.parse('text', 'abc | unknown | nothing at all | whaaat', compiler)
|
|
|
assert.strictEqual(d.filters, null)
|
|
|
assert.strictEqual(e.filters, null, 'single')
|
|
|
assert.strictEqual(f.filters, null, 'double')
|
|
|
@@ -193,7 +193,7 @@ describe('UNIT: Directive', function () {
|
|
|
})
|
|
|
|
|
|
it('should extract correct filters (single filter)', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc || a + "b|c" | uppercase', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc || a + "b|c" | uppercase', compiler),
|
|
|
f = d.filters[0]
|
|
|
assert.strictEqual(f.name, 'uppercase')
|
|
|
assert.strictEqual(f.args, null)
|
|
|
@@ -201,7 +201,7 @@ describe('UNIT: Directive', function () {
|
|
|
})
|
|
|
|
|
|
it('should extract correct filters (single filter with args)', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc + \'b | c | d\' | pluralize item \'arg with spaces\'', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc + \'b | c | d\' | pluralize item \'arg with spaces\'', compiler),
|
|
|
f = d.filters[0]
|
|
|
assert.strictEqual(f.name, 'pluralize', 'name')
|
|
|
assert.strictEqual(f.args.length, 2, 'args length')
|
|
|
@@ -211,7 +211,7 @@ describe('UNIT: Directive', function () {
|
|
|
|
|
|
it('should extract correct filters (multiple filters)', function () {
|
|
|
// intentional double pipe
|
|
|
- var d = Directive.parse('v-text', 'abc | uppercase | pluralize item || lowercase', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc | uppercase | pluralize item || lowercase', compiler),
|
|
|
f1 = d.filters[0],
|
|
|
f2 = d.filters[1],
|
|
|
f3 = d.filters[2]
|
|
|
@@ -227,7 +227,7 @@ describe('UNIT: Directive', function () {
|
|
|
describe('.applyFilters()', function () {
|
|
|
|
|
|
it('should work', function () {
|
|
|
- var d = Directive.parse('v-text', 'abc | pluralize item | capitalize', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc | pluralize item | capitalize', compiler),
|
|
|
v = d.applyFilters(2)
|
|
|
assert.strictEqual(v, 'Items')
|
|
|
})
|
|
|
@@ -241,13 +241,13 @@ describe('UNIT: Directive', function () {
|
|
|
directives.applyTest = applyTest
|
|
|
|
|
|
it('should invole the _update function', function () {
|
|
|
- var d = Directive.parse('v-applyTest', 'abc', compiler)
|
|
|
+ var d = Directive.parse('applyTest', 'abc', compiler)
|
|
|
d.apply(12345)
|
|
|
assert.strictEqual(test, 12345)
|
|
|
})
|
|
|
|
|
|
it('should apply the filter if there is any', function () {
|
|
|
- var d = Directive.parse('v-applyTest', 'abc | currency £', compiler)
|
|
|
+ var d = Directive.parse('applyTest', 'abc | currency £', compiler)
|
|
|
d.apply(12345)
|
|
|
assert.strictEqual(test, '£12,345.00')
|
|
|
})
|
|
|
@@ -256,7 +256,7 @@ describe('UNIT: Directive', function () {
|
|
|
|
|
|
describe('.update()', function () {
|
|
|
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc', compiler),
|
|
|
applied = false
|
|
|
d.apply = function () {
|
|
|
applied = true
|
|
|
@@ -284,7 +284,7 @@ describe('UNIT: Directive', function () {
|
|
|
|
|
|
describe('.refresh()', function () {
|
|
|
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc', compiler),
|
|
|
applied = false,
|
|
|
el = 1, vm = 2,
|
|
|
value = {
|
|
|
@@ -322,7 +322,7 @@ describe('UNIT: Directive', function () {
|
|
|
|
|
|
describe('.unbind()', function () {
|
|
|
|
|
|
- var d = Directive.parse('v-text', 'abc', compiler),
|
|
|
+ var d = Directive.parse('text', 'abc', compiler),
|
|
|
unbound = false,
|
|
|
val
|
|
|
d._unbind = function (v) {
|
|
|
@@ -357,7 +357,7 @@ describe('UNIT: Directive', function () {
|
|
|
called++
|
|
|
}
|
|
|
Vue.directive('simple-dir-test1', call)
|
|
|
- var d = Directive.parse('v-simple-dir-test1', '', compiler)
|
|
|
+ var d = Directive.parse('simple-dir-test1', '', compiler)
|
|
|
d.bind()
|
|
|
assert.strictEqual(called, 1)
|
|
|
})
|
|
|
@@ -371,7 +371,7 @@ describe('UNIT: Directive', function () {
|
|
|
bind: call,
|
|
|
unbind: call
|
|
|
})
|
|
|
- var d = Directive.parse('v-simple-dir-test2', '', compiler, true)
|
|
|
+ var d = Directive.parse('simple-dir-test2', '', compiler, true)
|
|
|
d.bind()
|
|
|
d.unbind()
|
|
|
assert.strictEqual(called, 2)
|