<commit_before>/* eslint-disable */
import assert from 'assert'
import { transform } from 'babel-standalone'

// SET TO TRUE WHEN QA IS COMPLETE:
export const QA = true;

// ---------------------------- define challenge title ----------------------------
export const challengeTitle = `<span class = 'default'>Challenge: </span>Copy an Object with Object.assign`

// ---------------------------- challenge text ----------------------------
export const challengeText = `<span class = 'default'>Intro: </span>The last several challenges worked with arrays, but there are ways to help enforce state immutability when state is an <code>object</code>, too. A useful tool for handling objects is the <code>Object.assign()</code> utility. <code>Object.assign()</code> takes a target object and source objects and maps properties from the source objects to the target object. Any matching properties are overwritten by properties in the source objects. This behavior is commonly used to make shallow copies of objects by passing an empty object as the first argument followed by the object(s) you want to copy. Here's an example:
<br><br>

<code>const newObject = Object.assign({}, obj1, obj2);</code>
<br><br>

This creates <code>newObject</code> as a new <code>object</code>, which contains the properties that currently exist in <code>obj1</code> and <code>obj2</code>.`

// ---------------------------- challenge instructions ----------------------------
export const challengeInstructions = `<span class = 'default'>Instructions: </span>The Redux state and actions were modified to handle an <code>object</code> for the <code>state</code>. Edit the code to return a new <code>state</code> object for actions with type <code>ONLINE</code>, which set the <code>status</code> property to the string <code>online</code>. Try to use <code>Object.assign()</code> to complete the challenge.`

// ---------------------------- define challenge seed code ----------------------------
export const seedCode =
`const ONLINE = 'ONLINE';

const defaultState = {
	user: 'CamperBot',
  status: 'offline',
  friends: '732,982',
  community: 'Free Code Camp'
};

const immutableReducer = (state = defaultState, action) => {
	switch(action.type) {
		case ONLINE:
			return // don't mutate state here
		default:
			return state;
	}
};

const wakeUp = () => {
	return {
		type: ONLINE,
	}
};

const store = Redux.createStore(immutableReducer);`

// ---------------------------- define challenge solution code ----------------------------
export const solutionCode =
`const ONLINE = 'ONLINE';

const defaultState = {
	user: 'CamperBot',
  status: 'offline',
  friends: '732,982',
  community: 'Free Code Camp'
};

const immutableReducer = (state = defaultState, action) => {
	switch(action.type) {
		case ONLINE:
			return Object.assign(
				{},
				state,
        {status: 'online'}
			);
		default:
			return state;
	}
};

const wakeUp = () => {
	return {
		type: ONLINE,
	}
};

const store = Redux.createStore(immutableReducer);`

// ---------------------------- define challenge tests ----------------------------

export const executeTests = (code) => {

	const error_0 = 'Your code should transpile successfully.';
	const error_1 = 'The Redux store should exist and initialize with a state that\'s an object with keys \'user\', \'status\', \'friends\', and \'community\'';
	const error_2 = 'wakeUp and immutableReducer both should be functions.';
	const error_3 = 'Dispatching an action of type \'ONLINE\' should update the property \'status\' in state to \'online\' and return a new state object.';

	let testResults = [
		{
			test: 0,
			status: false,
			condition: error_0
		},
		{
			test: 1,
			status: false,
			condition: error_1
		},
		{
			test: 2,
			status: false,
			condition: error_2<commit_msg>updated Redux 17<commit_after>/* eslint-disable */
import assert from 'assert'
import { transform } from 'babel-standalone'

// SET TO TRUE WHEN QA IS COMPLETE:
export const QA = true;

// ---------------------------- define challenge title ----------------------------
export const challengeTitle = `<span class = 'default'>Challenge: </span>Copy an Object with Object.assign`

// ---------------------------- challenge text ----------------------------
export const challengeText = `<span class = 'default'>Intro: </span>The last several challenges worked with arrays, but there are ways to help enforce state immutability when state is an <code>object</code>, too. A useful tool for handling objects is the <code>Object.assign()</code> utility. <code>Object.assign()</code> takes a target object and source objects and maps properties from the source objects to the target object. Any matching properties are overwritten by properties in the source objects. This behavior is commonly used to make shallow copies of objects by passing an empty object as the first argument followed by the object(s) you want to copy. Here's an example:
<br><br>

<code>const newObject = Object.assign({}, obj1, obj2);</code>
<br><br>

This creates <code>newObject</code> as a new <code>object</code>, which contains the properties that currently exist in <code>obj1</code> and <code>obj2</code>.`

// ---------------------------- challenge instructions ----------------------------
export const challengeInstructions = `<span class = 'default'>Instructions: </span>The Redux state and actions were modified to handle an <code>object</code> for the <code>state</code>. Edit the code to return a new <code>state</code> object for actions with type <code>ONLINE</code>, which set the <code>status</code> property to the string <code>online</code>. Try to use <code>Object.assign()</code> to complete the challenge.`

// ---------------------------- define challenge seed code ----------------------------
export const seedCode =
`const ONLINE = 'ONLINE';

const defaultState = {
	user: 'CamperBot',
  status: 'offline',
  friends: '732,982',
  community: 'Free Code Camp'
};

const immutableReducer = (state = defaultState, action) => {
	switch(action.type) {
		case ONLINE:
			return // don't mutate state here
		default:
			return state;
	}
};

const wakeUp = () => {
	return {
		type: ONLINE
	}
};

const store = Redux.createStore(immutableReducer);`

// ---------------------------- define challenge solution code ----------------------------
export const solutionCode =
`const ONLINE = 'ONLINE';

const defaultState = {
	user: 'CamperBot',
  status: 'offline',
  friends: '732,982',
  community: 'Free Code Camp'
};

const immutableReducer = (state = defaultState, action) => {
	switch(action.type) {
		case ONLINE:
			return Object.assign(
				{},
				state,
        {status: 'online'}
			);
		default:
			return state;
	}
};

const wakeUp = () => {
	return {
		type: ONLINE
	}
};

const store = Redux.createStore(immutableReducer);`

// ---------------------------- define challenge tests ----------------------------

export const executeTests = (code) => {

	const error_0 = 'Your code should transpile successfully.';
	const error_1 = 'The Redux store should exist and initialize with a state that\'s an object with keys \'user\', \'status\', \'friends\', and \'community\'';
	const error_2 = 'wakeUp and immutableReducer both should be functions.';
	const error_3 = 'Dispatching an action of type \'ONLINE\' should update the property \'status\' in state to \'online\' and return a new state object.';

	let testResults = [
		{
			test: 0,
			status: false,
			condition: error_0
		},
		{
			test: 1,
			status: false,
			condition: error_1
		},
		{
			test: 2,
			status: false,
			condition: error_2
{'fraction_non_alphanumeric': 0.19612495057334914, 'fraction_numerical': 0.0071174377224199285, 'mean_word_length': 2.721432074546346, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114879', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2053, 'n_words': 789}