source: Dev/trunk/node_modules/grunt-banner/test/banner_test.js

Last change on this file was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 2.0 KB
RevLine 
[484]1'use strict';
2
3var grunt = require('grunt');
4
5/*
6  ======== A Handy Little Nodeunit Reference ========
7  https://github.com/caolan/nodeunit
8
9  Test methods:
10    test.expect(numAssertions)
11    test.done()
12  Test assertions:
13    test.ok(value, [message])
14    test.equal(actual, expected, [message])
15    test.notEqual(actual, expected, [message])
16    test.deepEqual(actual, expected, [message])
17    test.notDeepEqual(actual, expected, [message])
18    test.strictEqual(actual, expected, [message])
19    test.notStrictEqual(actual, expected, [message])
20    test.throws(block, [error], [message])
21    test.doesNotThrow(block, [error], [message])
22    test.ifError(value)
23*/
24
25exports.banner = {
26
27    setUp: function( done ) {
28        // setup here if necessary
29        done();
30    },
31
32    tearDown: function( done ) {
33        // tear down here if necessary
34        // tear down currently happens after the last test (bannerBottom) @todo fix this
35
36        done();
37    },
38
39    bannerTop: function( test ) {
40        test.expect( 1 );
41
42        var actual = grunt.file.read( 'test/fixtures/some.js' );
43        var expected = grunt.file.read( 'test/expected/some-banner.js' );
44
45        test.equal( actual, expected, 'should add a banner to the top of a file' );
46
47        test.done();
48    },
49
50    bannerBottom: function( test ) {
51        test.expect( 1 );
52
53        var actual = grunt.file.read( 'test/fixtures/someBottom.js' );
54        var expected = grunt.file.read( 'test/expected/some-bottom.js' );
55
56        test.equal( actual, expected, 'should add a banner to the bottom of a file' );
57
58        test.done();
59
60        // @todo fix this tear down
61        var filePath = [
62            'test/fixtures/some.js',
63            'test/fixtures/someBottom.js'
64        ];
65
66        filePath.forEach( function( file ) {
67            // delete test file if it currently exists
68            if ( grunt.file.exists( file ) ) {
69                grunt.file.delete( file );
70            }
71
72            // Write the post-test file
73            grunt.file.write( file, 'var variable = "this is a variable"' );
74        });
75    }
76};
Note: See TracBrowser for help on using the repository browser.