Skip to content

Commit

Permalink
Add fixtures for resistor-color (#24)
Browse files Browse the repository at this point in the history
Fixtures for #13
  • Loading branch information
SleeplessByte authored Jun 6, 2019
1 parent 413419e commit 4c22541
Show file tree
Hide file tree
Showing 510 changed files with 5,472 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/fixtures/resistor-color/0/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const COLORS = [
"black",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"violet",
"grey",
"white"
];

export const colorCode = color => COLORS.indexOf(color);
21 changes: 21 additions & 0 deletions test/fixtures/resistor-color/0/resistor-color.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { colorCode, COLORS } from './resistor-color'

describe('ResistorColor', () => {
describe('Color codes', () => {
test('Black', () => {
expect(colorCode("black")).toEqual(0)
})

test('White', () => {
expect(colorCode("white")).toEqual(9)
})

test('Orange', () => {
expect(colorCode("orange")).toEqual(3)
})
})

test('Colors', () => {
expect(COLORS).toEqual(["black","brown","red","orange","yellow","green","blue","violet","grey","white"])
})
})
4 changes: 4 additions & 0 deletions test/fixtures/resistor-color/1/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"];

export const colorCode = color => COLORS.indexOf(color);

16 changes: 16 additions & 0 deletions test/fixtures/resistor-color/10/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const color_dict = {
'black': 0,
'brown': 1,
'red': 2,
'orange': 3,
'yellow': 4,
'green': 5,
'blue': 6,
'violet': 7,
'grey': 8,
'white': 9
}
export const colorCode = (COLOR) => {
return color_dict[COLOR]
}
export const COLORS = Object.keys(color_dict)
2 changes: 2 additions & 0 deletions test/fixtures/resistor-color/100/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"],
colorCode = (color) => COLORS.indexOf(color);
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/101/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export let colorCode = (band) => COLORS.indexOf(band);

export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/102/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"];

export function colorCode(color) {
return COLORS.indexOf(color);
}
18 changes: 18 additions & 0 deletions test/fixtures/resistor-color/103/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const COLORS = [
'black',
'brown',
'red',
'orange',
'yellow',
'green',
'blue',
'violet',
'grey',
'white'
]

function colorCode (color) {
return COLORS.indexOf(color.toLowerCase())
}

export { colorCode, COLORS }
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/104/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];

export const colorCode = (color) => {
for(let i = 0; i < COLORS.length; i++){ if (COLORS[i] == color){ return i } }
}
13 changes: 13 additions & 0 deletions test/fixtures/resistor-color/105/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable no-empty */
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
export const COLORS = ["black","brown","red","orange","yellow",
"green","blue","violet","grey","white"];

export const colorCode = (color) => COLORS.indexOf(color);




//console.log(COLORS);
console.log(colorCode("white"));
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/106/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"]

export function colorCode (color) {
return COLORS.indexOf(color)
}
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/107/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];

export const colorCode = color => COLORS.indexOf(color);
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/108/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"]

export const colorCode = color => COLORS.indexOf(color.toLowerCase())
8 changes: 8 additions & 0 deletions test/fixtures/resistor-color/109/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"]
export const colorCode = (color) => {
for (let i = 0; i < COLORS.length; i++) {
if (COLORS[i] === color) {
return i
}
}
}
30 changes: 30 additions & 0 deletions test/fixtures/resistor-color/11/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const colorCode = (color) => {
for(var i = 0; i < COLORS.length; i++) {
if (COLORS[i] == color) {
return i;
}
}
}

export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"];



/**
*
Resistors have color coded bands, where each color maps to a number. The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number.
These colors are encoded as follows:
Black: 0
Brown: 1
Red: 2
Orange: 3
Yellow: 4
Green: 5
Blue: 6
Violet: 7
Grey: 8
White: 9
Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: Better Be Right Or Your Great Big Values Go Wrong.
*/
15 changes: 15 additions & 0 deletions test/fixtures/resistor-color/110/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const COLORS =
[
'black',
'brown',
'red',
'orange',
'yellow',
'green',
'blue',
'violet',
'grey',
'white'
];

export const colorCode = (color) => COLORS.indexOf(color);
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/111/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const colorCode = (code) => COLORS.indexOf(code);
const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];
export { colorCode, COLORS };
16 changes: 16 additions & 0 deletions test/fixtures/resistor-color/112/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const COLORS = [
"black",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"violet",
"grey",
"white"
];

const colorCode = color => COLORS.indexOf(color);

export { colorCode, COLORS };
6 changes: 6 additions & 0 deletions test/fixtures/resistor-color/113/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const COLORS = [
'black', 'brown', 'red', 'orange', 'yellow', 'green',
'blue', 'violet', 'grey', 'white',
]

export const colorCode = color => COLORS.indexOf(color)
6 changes: 6 additions & 0 deletions test/fixtures/resistor-color/114/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"];

export function colorCode(color) {
let resistorColor = color.toLowerCase();
return COLORS.indexOf(resistorColor);
}
12 changes: 12 additions & 0 deletions test/fixtures/resistor-color/115/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Simple mapping resistors colors to numbers
*/

// Defining colors in order
export const COLORS = ["black", "brown", "red", "orange", "yellow", "green",
"blue", "violet", "grey", "white"];

// Function to return index of a specific color
export function colorCode(color) {
return COLORS.indexOf(color);
}
19 changes: 19 additions & 0 deletions test/fixtures/resistor-color/116/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export let COLORS = [
"black",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"violet",
"grey",
"white"
];

/**
* Returns index of `color` in COLORS array
* @param {String} color
*/
export let colorCode =
color => COLORS.findIndex(item => color === item);
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/117/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const colorCode = (color) => COLORS.indexOf(color);

export const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"]
16 changes: 16 additions & 0 deletions test/fixtures/resistor-color/118/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const COLORS = [
'black',
'brown',
'red',
'orange',
'yellow',
'green',
'blue',
'violet',
'grey',
'white'
];

const colorCode = color => COLORS.findIndex(element => element === color);

export { COLORS, colorCode };
4 changes: 4 additions & 0 deletions test/fixtures/resistor-color/119/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"]
export const colorCode = (color,colors=["black","brown","red","orange","yellow","green","blue","violet","grey","white"]) => {
return colors.indexOf(color)
}
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/12/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];

export function colorCode(color) {
return COLORS.indexOf(color);
}
7 changes: 7 additions & 0 deletions test/fixtures/resistor-color/120/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export let COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];
export function colorCode(color) {
for(let i = 0; i<COLORS.length; i++){
if(color === COLORS[i])
return i;
}
};
7 changes: 7 additions & 0 deletions test/fixtures/resistor-color/121/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"]
const colorCode = (color)=> COLORS.indexOf(color)

export {
COLORS,
colorCode
}
3 changes: 3 additions & 0 deletions test/fixtures/resistor-color/122/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];

export const colorCode = (color) => COLORS.indexOf(color);
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/123/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = ['black', 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'grey', 'white'];

export const colorCode = (color) => {
return COLORS.indexOf(color);
}
23 changes: 23 additions & 0 deletions test/fixtures/resistor-color/124/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const colorMap = {
"black": 0,
"brown": 1,
"red": 2,
"orange": 3,
"yellow": 4,
"green": 5,
"blue": 6,
"violet": 7,
"grey": 8,
"white": 9
}

const colorCode = (color) => {
return colorMap[color];
}

const COLORS = Object.keys(colorMap)

export {
colorCode,
COLORS
}
4 changes: 4 additions & 0 deletions test/fixtures/resistor-color/125/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const COLORS = ["black","brown","red","orange","yellow","green","blue","violet","grey","white"];

export const colorCode = color => COLORS.indexOf(color.toLowerCase());

21 changes: 21 additions & 0 deletions test/fixtures/resistor-color/126/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const COLORS = [
'black',
'brown',
'red',
'orange',
'yellow',
'green',
'blue',
'violet',
'grey',
'white'
];

export const CODES = COLORS.reduce((accum, color, i) => {
accum[color] = i;
return accum;
}, {});

export const colorCode = (color) => {
return CODES[color];
};
5 changes: 5 additions & 0 deletions test/fixtures/resistor-color/127/rc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COLORS = [ "black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white" ];

export const colorCode = function(colorName) {
return COLORS.indexOf(colorName);
}
2 changes: 2 additions & 0 deletions test/fixtures/resistor-color/128/resistor-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const COLORS = ['black','brown','red','orange','yellow','green','blue','violet','grey','white']
export const colorCode = (color, list = COLORS ) => list.indexOf(color) > -1 ? list.indexOf(color) : null;
Loading

0 comments on commit 4c22541

Please sign in to comment.