Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bootlint_test.js « test - github.com/twbs/grunt-bootlint.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 466b2b450fe8bf9cb2dee38325e175e5dc020f3c (plain)
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
'use strict';

var grunt = require('grunt');

/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

exports.bootlint = {
  setUp: function(done) {
    // setup here if necessary
    done();
  },
  default_options: function(test) {
    test.expect(4);
    grunt.util.spawn({
      grunt: true,
      args: ['bootlint:default_options', '--no-color'],
    }, function(err, result) {
      test.ok(result.stdout.indexOf("Validation started for") >= 0,
        'Should print start msg');
      test.ok(result.stdout.indexOf("test/fixtures/missing-doctype.html") >= 0,
        'Should print file path');
      test.ok(result.stdout.indexOf("Document is missing a DOCTYPE declaration") >= 0,
        'Should warn about missing a DOCTYPE');
      test.ok(result.stdout.indexOf("2 lint errors found") >= 0,
        'Should print number of lint errors');
      test.done();
    });
  },
  custom_options: function(test) {
    test.expect(2);
    grunt.util.spawn({
      grunt: true,
      args: ['bootlint:custom_options', '--no-color'],
    }, function(err, result) {
      test.ok(result.stdout.indexOf("Document is missing a DOCTYPE declaration") === -1,
        'Should not warn about missing a DOCTYPE');
      test.ok(result.stdout.indexOf("1 lint errors found") >= 0,
        'Should print correct number of lint errors');
      test.done();
    });
  },
  pass: function(test) {
    test.expect(1);
    grunt.util.spawn({
      grunt: true,
      args: ['bootlint:pass', '--no-color'],
    }, function(err, result) {
      test.ok(result.stdout.indexOf("No Bootlint errors!") >= 0,
        'Should print "No Bootlint errors!" message');
      test.done();
    });
  },
};