File containing JavaScript must have ".js" extension.
Bad:
index.jsx
var SeminarFactory = { | |
create: function (overwrite) { | |
var defaultData, | |
objectData; | |
defaultData = { | |
name: 'JavaScript basics', | |
price: 100 | |
}; |
describe('Seminar', function () { | |
it('has a name', function () { | |
var seminar = SeminarFactory.create({name: 'JavaScript'}); | |
expect(seminar.getName()).toEqual('JavaScript'); | |
}); | |
it('has a price', function () { | |
var seminar = SeminarFactory.create({price: 10}); |
// The hash (#) and dot (.) symbols are a convention to mark if a method | |
// is called on an individual object or on the prototype. ".create" is | |
// called on the Cart prototype. #add are called on the derived objects. | |
describe('Cart', function () { | |
var cart; | |
beforeEach(function () { | |
cart = Cart.create(); | |
}); | |
describe('.create', function () { |
describe('A Cart with a several different products', function () { | |
var cart; | |
beforeEach(function () { | |
cart = Cart.create(); | |
}); | |
it('must have a #grossPriceSum() of the contained products', function () { | |
var product = Product.create('A', 10), | |
book = Book.create('B', 100); |
describe('Product', function () { | |
it('must calculate its gross price by adding the VAT', function () { | |
var product = Product.create('A', 10); | |
expect(product.grossPrice()).toEqual(12); | |
}); | |
}); |
var todoApp; | |
todoApp = angular.module('todoApp', []); | |
todoApp.controller('TodoController', function ($scope) { | |
$scope.todo = { | |
user: 'Adam', | |
items: [ | |
{name: 'Get the book', done: true}, | |
{name: 'Finish reading the book', done: false}, |
<!DOCTYPE html> | |
<html ng-app="todoApp"> | |
<head> | |
<title>First Test</title> | |
<script src="../angular.js"></script> | |
<script src="./todo.js"></script> | |
<style> | |
.warning { color: #f00; } | |
.success { color: #0f0; } |
<!DOCTYPE html> | |
<html ng-app="todoApp"> | |
<head> | |
<title>First Test</title> | |
<script src="../angular.js"></script> | |
<script src="./todo.js"></script> | |
<style> | |
.warning { color: #f00; } | |
.success { color: #0f0; } |
<!DOCTYPE html> | |
<html ng-app="todoApp"> | |
<head> | |
<title>First Test</title> | |
<script src="../angular.js"></script> | |
<script src="./todo.js"></script> | |
<style> | |
.warning { color: #f00; } | |
.success { color: #0f0; } |