Skip to content

Commit

Permalink
6/4/2021
Browse files Browse the repository at this point in the history
  • Loading branch information
nagulan23 committed Apr 6, 2021
1 parent ec4abad commit da5a3c8
Show file tree
Hide file tree
Showing 12 changed files with 1,462 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .scannerwork/report-task.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ projectKey=aglm-demo
serverUrl=http://localhost:9000
serverVersion=8.7.1.42226
dashboardUrl=http://localhost:9000/dashboard?id=aglm-demo
ceTaskId=AXiiNuzfYOvwZdFwSNSF
ceTaskUrl=http://localhost:9000/api/ce/task?id=AXiiNuzfYOvwZdFwSNSF
ceTaskId=AXiiQelYVeVWuMw-lrwj
ceTaskUrl=http://localhost:9000/api/ce/task?id=AXiiQelYVeVWuMw-lrwj
1,344 changes: 1,219 additions & 125 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"bootstrap": "^4.6.0",
"create-react-native-app": "^3.6.0",
"dotenv": "^8.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"firebase": "^8.2.9",
"latest-version": "^5.1.0",
"multiselect-react-dropdown": "^1.6.11",
Expand All @@ -30,14 +32,15 @@
"react-scroll-horizontal": "^1.6.6",
"react-spinkit": "^3.0.0",
"react-spring": "^8.0.27",
"react-test-renderer": "^17.0.2",
"react-use-gesture": "^9.1.1",
"web-vitals": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"test": "react-scripts test"
},
"eslintConfig": {
"extends": [
Expand All @@ -56,5 +59,10 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/plugin-syntax-jsx": "^7.12.13",
"@babel/preset-react": "^7.13.13",
"jest": "^26.6.0"
}
}
8 changes: 8 additions & 0 deletions src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": ["@babel/preset-env"],
"env": {
"test": {
"presets": ["@babel/preset-env"]
}
}
}
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class App extends Component {
}
console.log(this.state);
}

state = {
redirect: "",
userID: "",
Expand Down
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/components/home page/count.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ class CountBox extends Component {

constructor() {
super();
this.getdata = this.getdata.bind(this);
this.getdata();
}

async getdata() {
await axios
.post(`https://aglm.herokuapp.com/countlectures`, {
uid: localStorage.getItem("userID"),
})
.then((res) => {
}).then((res) => {
this.setState({ count: res.data });
});
}


state = {
count:{
present:0,
Expand Down
31 changes: 31 additions & 0 deletions src/components/home page/count.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//import { render, screen } from '@testing-library/react';
//import CountBox from 'src/components/home pages/count'
//const App = require('./App.js')
import CountBox from './count.js';
import React from 'react';
import { Enzyme, EnzymeAdapter, shallow} from 'enzyme';
import {configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({adapter: new Adapter() });

describe('<CountBox />', () => {
it('Checking count getdata',async () => {
const wrapper = shallow(<CountBox />);
const instance=wrapper.instance();
var orgdata=wrapper.state().count;
var c=0;
for(var key in orgdata)
if(orgdata[key]===0)
c++;
expect(c).toBe(3);
localStorage.setItem('userID',"jFRWF4kP5HfyPNgDyJUiG83Oc8k1");
await instance.getdata();
var data=wrapper.state().count;
var c=0;
for(var key in data)
c++;
expect(c).toBe(3);
localStorage.clear();
});
});
2 changes: 1 addition & 1 deletion src/components/home page/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Header extends Component {
};
constructor() {
super();
this.getdata = this.getdata.bind(this);
this.getdata();
}

Expand All @@ -27,7 +28,6 @@ class Header extends Component {
uid: localStorage.getItem("userID"),
})
.then((res) => {
console.log(res.data);
if (res.data.type === "user") {
window.user = { roll_no: res.data.roll_no };
} else if (res.data.type === "guser") {
Expand Down
49 changes: 49 additions & 0 deletions src/components/home page/header.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Header from "./header.js";
import React from "react";
import { Enzyme, EnzymeAdapter, shallow } from "enzyme";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

configure({ adapter: new Adapter() });

describe("<Header />", () => {
it("Checking roll number getdata", async () => {
const wrapper = shallow(<Header.WrappedComponent />);
const instance = wrapper.instance();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("Loading...");
localStorage.setItem("userID", "jFRWF4kP5HfyPNgDyJUiG83Oc8k1");
await instance.getdata();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("cb.en.u4cse18135");
localStorage.clear();
});
});

describe("<Header />", () => {
it("Checking roll number getdata", async () => {
const wrapper = shallow(<Header.WrappedComponent />);
const instance = wrapper.instance();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("Loading...");
localStorage.setItem("userID", "Aaaoa9S8vLOR1DzkpanCcNaMH3G3");
await instance.getdata();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("Guest User");
localStorage.clear();
});
});

describe("<Header />", () => {
it("Checking roll number getdata", async () => {
const wrapper = shallow(<Header.WrappedComponent />);
const instance = wrapper.instance();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("Loading...");
localStorage.setItem("userID", "UwkudJJO1HO7Z50pOGgI7ODcPhw1");
await instance.getdata();
var orgdata = wrapper.state().roll_no;
expect(orgdata).toBe("ADMIN");
localStorage.clear();
});
});
2 changes: 2 additions & 0 deletions src/components/home page/lecture_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class Lecture_card extends Component {
//this.props.setDataLecture(this);
this.props.history.push("/lecture");
window.scrollTo(0, 0);
return("success");
}
return("failure");
}

render() {
Expand Down
136 changes: 136 additions & 0 deletions src/components/home page/lecture_card.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import Lecture_card from "./lecture_card.js";
import React from "react";
import { Enzyme, EnzymeAdapter, shallow } from "enzyme";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

configure({ adapter: new Adapter() });
window.scrollTo = jest.fn();
describe("<Lecture_card />", () => {
it("Checking movement to next page", () => {
const historyMock = { push: jest.fn() };
const wrapper = shallow(
<Lecture_card.WrappedComponent
history={historyMock}
setDataLecture={jest.fn()}
details={{
regcount: "100",
poster:
"https://i2.wp.com/psychlearningcurve.org/wp-content/uploads/2019/12/skills.png?fit=1000%2C563",
organizer: "Amrita Vishwa Vidhyapeetam",
title: "Introduction to Psychology",
about:
"What are people most afraid of? What do our dreams mean? Are we natural-born racists? What makes us happy? What are the causes and cures of mental illness? This course tries to answer these questions and many others, providing a comprehensive overview of the scientific study of thought and behavior. It explores topics such as perception, communication, learning, memory, decision-making, persuasion, emotions, and social behavior. We will look at how these aspects of the mind develop in children, how they differ across people, how they are wired-up in the brain, and how they break down due to illness and injury.",
syllabus: [
"Welcome to Introduction to Psychology",
"Foundations",
"Development and Language",
"Cognition",
"Self and others",
],
requirements: ["All", "Every year", "None"],
fee: "300",
instructor: {
name: "Dr. Gitanjali Natarajan",
img:
"https://www.amrita.edu/sites/default/files/styles/260x160/adaptive-image/public/faculty_images/gitanjali-n.jpg?itok=e2mmhRHV",
position: "Licensed Clinical Psychologist",
},
geoinfo: {
stdate: "2021/04/03",
eddate: "2021/04/05",
sttime: "09:00",
edtime: "11:00",
venue: "AB-1,Lecture hall-3",
certificate: "E-Certificate",
},
lecture_id: "5",
registered: [
"ujGl7FVouFh2r75cWeRvEqj6CQR2",
"cO77kwy785eXoSeoVgXgr81T3cq1",
],
}}
/>
);
const instance = wrapper.instance();
expect(instance.openLecture()).toBe("success");
});
});

describe("<Lecture_card />", () => {
it("Checking movement to next page", () => {
const historyMock = { push: jest.fn() };
const wrapper = shallow(
<Lecture_card.WrappedComponent
history={historyMock}
setDataLecture={jest.fn()}
details={{
poster:
"https://t3.ftcdn.net/jpg/02/66/33/82/360_F_266338299_wTr8tcMGNmjFbEJVnrkKXrrsHABMlqXY.jpg",
title: "No Lectures to display right now!",
geoinfo: {
stdate: "",
eddate: "",
sttime: "",
edtime: "",
venue: "",
},
}}
/>
);
const instance = wrapper.instance();
expect(instance.openLecture()).toBe("failure");
});
});

describe("<Lecture_card />", () => {
it("Checking movement to next page", () => {
const historyMock = { push: jest.fn() };
const wrapper = shallow(
<Lecture_card.WrappedComponent
history={historyMock}
setDataLecture={jest.fn()}
details={{
regcount: "100",
poster:
"https://i2.wp.com/psychlearningcurve.org/wp-content/uploads/2019/12/skills.png?fit=1000%2C563",
organizer: "Amrita Vishwa Vidhyapeetam",
title: "Introduction to Psychology",
about:
"What are people most afraid of? What do our dreams mean? Are we natural-born racists? What makes us happy? What are the causes and cures of mental illness? This course tries to answer these questions and many others, providing a comprehensive overview of the scientific study of thought and behavior. It explores topics such as perception, communication, learning, memory, decision-making, persuasion, emotions, and social behavior. We will look at how these aspects of the mind develop in children, how they differ across people, how they are wired-up in the brain, and how they break down due to illness and injury.",
syllabus: [
"Welcome to Introduction to Psychology",
"Foundations",
"Development and Language",
"Cognition",
"Self and others",
],
requirements: ["All", "Every year", "None"],
fee: "300",
instructor: {
name: "Dr. Gitanjali Natarajan",
img:
"https://www.amrita.edu/sites/default/files/styles/260x160/adaptive-image/public/faculty_images/gitanjali-n.jpg?itok=e2mmhRHV",
position: "Licensed Clinical Psychologist",
},
geoinfo: {
stdate: "2021/04/03",
eddate: "2021/04/05",
sttime: "09:00",
edtime: "11:00",
venue: "AB-1,Lecture hall-3",
certificate: "E-Certificate",
},
lecture_id: "5",
registered: [
"ujGl7FVouFh2r75cWeRvEqj6CQR2",
"cO77kwy785eXoSeoVgXgr81T3cq1",
],
}}
/>
);
const instance = wrapper.instance();
instance.openLecture();
expect(global.scrollTo).toHaveBeenCalledWith(0, 0);
});
});

0 comments on commit da5a3c8

Please sign in to comment.