Skip to content

Commit

Permalink
ES2015ify the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 14, 2015
1 parent dbbc78f commit ccb7518
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
5 changes: 0 additions & 5 deletions package.json
Expand Up @@ -37,10 +37,5 @@
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"ignores": [
"fixture/**"
]
}
}
53 changes: 26 additions & 27 deletions test.js
@@ -1,20 +1,19 @@
'use strict';
var test = require('ava');
var fs = require('fs');
var path = require('path');
var detectIndent = require('./');
import test from 'ava';
import fs from 'fs';
import path from 'path';
import detectIndent from './';

function getFile(file) {
return fs.readFileSync(path.join(__dirname, file), 'utf8');
}

test('detect the indent of a file with space indent', function (t) {
test('detect the indent of a file with space indent', t => {
t.is(detectIndent(getFile('fixture/space.js')).indent, ' ');
t.end();
});

test('return indentation stats for spaces', function (t) {
var stats = detectIndent(getFile('fixture/space.js'));
test('return indentation stats for spaces', t => {
const stats = detectIndent(getFile('fixture/space.js'));
t.same(stats, {
amount: 4,
indent: ' ',
Expand All @@ -23,8 +22,8 @@ test('return indentation stats for spaces', function (t) {
t.end();
});

test('return indentation stats for tabs', function (t) {
var stats = detectIndent(getFile('fixture/tab-four.js'));
test('return indentation stats for tabs', t => {
const stats = detectIndent(getFile('fixture/tab-four.js'));
t.same(stats, {
amount: 4,
indent: '\t\t\t\t',
Expand All @@ -33,13 +32,13 @@ test('return indentation stats for tabs', function (t) {
t.end();
});

test('detect the indent of a file with tab indent', function (t) {
test('detect the indent of a file with tab indent', t => {
t.is(detectIndent(getFile('fixture/tab.js')).indent, '\t');
t.end();
});

test('return indentation stats for tabs', function (t) {
var stats = detectIndent(getFile('fixture/tab.js'));
test('return indentation stats for tabs', t => {
const stats = detectIndent(getFile('fixture/tab.js'));
t.same(stats, {
amount: 1,
indent: '\t',
Expand All @@ -48,13 +47,13 @@ test('return indentation stats for tabs', function (t) {
t.end();
});

test('detect the indent of a file with equal tabs and spaces', function (t) {
test('detect the indent of a file with equal tabs and spaces', t => {
t.is(detectIndent(getFile('fixture/mixed-tab.js')).indent, '\t');
t.end();
});

test('return indentation stats for equal tabs and spaces', function (t) {
var indent = detectIndent(getFile('fixture/mixed-tab.js'));
test('return indentation stats for equal tabs and spaces', t => {
const indent = detectIndent(getFile('fixture/mixed-tab.js'));
t.same(indent, {
amount: 1,
indent: '\t',
Expand All @@ -63,14 +62,14 @@ test('return indentation stats for equal tabs and spaces', function (t) {
t.end();
});

test('detect the indent of a file with mostly spaces', function (t) {
var stats = detectIndent(getFile('fixture/mixed-space.js'));
test('detect the indent of a file with mostly spaces', t => {
const stats = detectIndent(getFile('fixture/mixed-space.js'));
t.is(stats.indent, ' ');
t.end();
});

test('return indentation stats for mostly spaces', function (t) {
var stats = detectIndent(getFile('fixture/mixed-space.js'));
test('return indentation stats for mostly spaces', t => {
const stats = detectIndent(getFile('fixture/mixed-space.js'));
t.same(stats, {
amount: 4,
indent: ' ',
Expand All @@ -79,14 +78,14 @@ test('return indentation stats for mostly spaces', function (t) {
t.end();
});

test('detect the indent of a weirdly indented vendor prefixed CSS', function (t) {
var stats = detectIndent(getFile('fixture/vendor-prefixed-css.css'));
test('detect the indent of a weirdly indented vendor prefixed CSS', t => {
const stats = detectIndent(getFile('fixture/vendor-prefixed-css.css'));
t.is(stats.indent, ' ');
t.end();
});

test('return indentation stats for mostly spaces', function (t) {
var stats = detectIndent(getFile('fixture/vendor-prefixed-css.css'));
test('return indentation stats for mostly spaces', t => {
const stats = detectIndent(getFile('fixture/vendor-prefixed-css.css'));
t.same(stats, {
amount: 4,
indent: ' ',
Expand All @@ -95,13 +94,13 @@ test('return indentation stats for mostly spaces', function (t) {
t.end();
});

test('return `0` when there is no indentation', function (t) {
test('return `0` when there is no indentation', t => {
t.is(detectIndent('<ul></ul>').amount, 0);
t.end();
});

test('return indentation stats for no indentation', function (t) {
var stats = detectIndent('<ul></ul>');
test('return indentation stats for no indentation', t => {
const stats = detectIndent('<ul></ul>');
t.same(stats, {
amount: 0,
indent: '',
Expand Down

0 comments on commit ccb7518

Please sign in to comment.