Having trouble testing the value of myArray after pushing data to it. Despite my efforts, I keep encountering an error indicating that the array content does not match my static arr variable. Could someone kindly review my code below and shed light on what mistake I might be making, causing Jasmine to report the two arrays as unequal? Thank you.
describe('Controller: MainCtrl', function () {
var MainCtrl, scope;
beforeEach(module('myApp'));
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('Final ordered array of equation elements', function () {
var arr = ["1", "2", "3", ".test[]"];
expect(scope.myArray).toBe(arr);
});
});
angular.controller('MainCtrl', function MainCtrl($scope) {
$scope.myArray = [];
$scope.myStr = '123.test[]';
$scope.myArray.push($scope.myStr.slice(0,1),
$scope.myStr.slice(1,2),
$scope.myStr.slice(2,3),
$scope.myStr.slice(3));
console.log(myArray); //returns ["1", "2", "3", ".test[]"]
});