Ver código fonte

fix unit test cleanup in IE9

Evan You 11 anos atrás
pai
commit
8e9cbad2c3
2 arquivos alterados com 10 adições e 9 exclusões
  1. 8 7
      test/unit/specs/utils.js
  2. 2 2
      test/unit/utils/prepare.js

+ 8 - 7
test/unit/specs/utils.js

@@ -1,7 +1,6 @@
-/* global cleanupMocks, appendMock */
+/* global cleanupMock, appendMock */
 
 
 describe('Utils', function () {
 describe('Utils', function () {
-    afterEach(cleanupMocks)
 
 
     var utils = require('vue/src/utils'),
     var utils = require('vue/src/utils'),
         config = require('vue/src/config')
         config = require('vue/src/config')
@@ -242,8 +241,6 @@ describe('Utils', function () {
     })
     })
 
 
     describe('parseTemplateOption', function () {
     describe('parseTemplateOption', function () {
-        
-        afterEach(cleanupMocks)
 
 
         it('should convert a string template to a documentFragment', function () {
         it('should convert a string template to a documentFragment', function () {
             var template = '<div class="a">hi</div><p>ha</p>',
             var template = '<div class="a">hi</div><p>ha</p>',
@@ -328,16 +325,20 @@ describe('Utils', function () {
 
 
     describe('processOptions', function () {
     describe('processOptions', function () {
         
         
+        var el
+
         beforeEach(function() {
         beforeEach(function() {
             var id = 'utils-template-to-fragment',
             var id = 'utils-template-to-fragment',
-                template = '<div class="a">hi</div><p>ha</p>',
-                el = document.createElement('template')
+                template = '<div class="a">hi</div><p>ha</p>'
+            el = document.createElement('template')
             el.id = id
             el.id = id
             el.innerHTML = template
             el.innerHTML = template
             appendMock(el)
             appendMock(el)
         })
         })
 
 
-        afterEach(cleanupMocks)
+        afterEach(function () {
+            cleanupMock(el)
+        })
 
 
         var options = {
         var options = {
             partials: {
             partials: {

+ 2 - 2
test/unit/utils/prepare.js

@@ -15,8 +15,8 @@ function appendMock(el) {
     document.getElementById('test').appendChild(el)
     document.getElementById('test').appendChild(el)
 }
 }
 
 
-function cleanupMocks() {
-    document.getElementById('test').innerHTML = ''
+function cleanupMock(el) {
+    document.getElementById('test').removeChild(el)
 }
 }
 
 
 function mockHTMLEvent (type) {
 function mockHTMLEvent (type) {